<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('title')->default('')->comment('商品名称');
            $table->text('description')->comment('商品详情');
            $table->string('image')->default('')->comment('商品封面');
            $table->tinyInteger('on_sale')->default('1')->comment('是否正在售卖');
            $table->double('rating')->default('5.00')->comment('平均评分');
            $table->integer('sold_count')->default('0')->comment('销量');
            $table->integer('review_count')->default('0')->comment('评价数量');
            $table->decimal('price')->default('0')->comment('最低价格');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('products');
    }
}
